<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>
			房产管理(hanling添加优化)
		</title>
		<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="format-detection" content="telephone=no">
		<link rel="stylesheet" href="css/main.css" media="all">
		<script type="text/javascript" src="lib/loading/okLoading.js"></script>
		<script src="js/base.js"></script>
		<!--百度编辑器-->
		<script src="ueditor/ueditor.config.js"></script>
		<script src="ueditor/ueditor.all.min.js"></script>
		<script src="ueditor/lang/zh-cn/zh-cn.js"></script>
		<style>
			.imgs {
				display: none;
			}
		</style>
	</head>
	<body>
		<div class="x-nav">
			<span class="layui-breadcrumb">
				<a><cite>首页</cite></a>
				<a><cite>房产管理</cite></a>
				<a><cite>修改房产</cite></a>
			</span>
			<a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right"
				href="javascript:location.replace(location.href);" title="刷新"><i class="layui-icon"
					style="line-height:30px">ဂ</i></a>
		</div>
		<div class="x-body">
			<form class="layui-form layui-form-pane" action="" id="add">
				<div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
					<div class="layui-tab-content">
						<div class="layui-tab-item layui-show">
							<input type="hidden" name="id" value="" />

							<div class="layui-form-item">
								<label class="layui-form-label">
									<span class='x-red'>*</span>所属小区
								</label>
								<div class="layui-input-block">
									
									<select name="fangchan_id" id="fangchan_id">
										<!-- <option value="0">请选择</option> -->
										
									</select>
									<script>
										
										let fangchanString=localStorage.getItem("fangchan_edit");
										let fangchan=JSON.parse(fangchanString);
										let XiaoQuurl = "http://localhost:8080/wuye/XiaoQuController/selectXiaoQuAll";
										rest(XiaoQuurl, "get", null, function(r) {
											let arr=r.data;
											let innerHTML = "";
											for (let i = 0; i < arr.length; i++) {
												if(fangchan.id==arr[i].id){
													innerHTML = innerHTML + " <option value=\"" + arr[i].mingcheng + "\" selected>" + arr[i].mingcheng +
														"</option>";
												}else{
													innerHTML = innerHTML + " <option value=\"" + arr[i].mingcheng + "\" >" + arr[i].mingcheng +
														"</option>";
												}
											
											}
											document.getElementById("fangchan_id").innerHTML = innerHTML;
										});
									</script>
								</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">
									<span class='x-red'>*</span>栋数
								</label>
								<div class="layui-input-block">
									<select name="building_id" id="building_id">
																				
									</select>
									<script>
										
										let FangChanurl = "http://localhost:8080/wuye/FangChanController/selectFangChanAll";
										rest(FangChanurl, "get", null, function(r) {
											let arr = r.data;
											let innerHTML = "";
											for (let i = 0; i < arr.length; i++) {
												if(fangchan.id==arr[i].id){
													innerHTML = innerHTML + " <option value=\"" + arr[i].dongshu  + "\" selected>" + arr[i].dongshu +
														"</option>";
												}else{
													innerHTML = innerHTML + " <option value=\"" + arr[i].dongshu + "\" >" + arr[i].dongshu +
														"</option>";
												}
											
											}
											document.getElementById("building_id").innerHTML = innerHTML;
										});
									</script>
								</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">
									<span class='x-red'>*</span>房产名称
								</label>
								<div class="layui-input-block">
									<input id="fangchanmingcheng" type="text" name="home_name" autocomplete="off"
										placeholder="控制在80个汉字，160个字符以内" class="layui-input" value="">
								</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">
									<span class='x-red'>*</span>户主名称
								</label>
								<div class="layui-input-block">
									<input id="huzhumingcheng" type="text" name="householder" autocomplete="off"
										placeholder="" class="layui-input" value="">
								</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">
									<span class='x-red'>*</span>联系方式
								</label>
								<div class="layui-input-block">
									<input id="telephone" type="text" name="phone" autocomplete="off" placeholder=""
										class="layui-input" lay-verify="required|phone" value="">
								</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">
									<span class='x-red'>*</span>房间数
								</label>
								<div class="layui-input-block">
									<input id="fangjianshu" type="text" name="home_number" autocomplete="off"
										placeholder="" class="layui-input" lay-verify="required|number" value="">
								</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">
									<span class='x-red'>*</span>单元
								</label>
								<div class="layui-input-block">
									<input id="danyuanhao" type="text" name="unit_building" autocomplete="off"
										placeholder="请输入数字" class="layui-input" lay-verify="required|number" value="">
								</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">
									<span class='x-red'>*</span>楼层
								</label>
								<div class="layui-input-block">
									<input id="loucenghao" type="text" name="floor" autocomplete="off"
										placeholder="请输入数字" class="layui-input" lay-verify="required|number" value="">
								</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">
									<span class='x-red'>*</span>入住时间
								</label>

								<div class="layui-input-inline">
									<input  class="layui-input" name="rz_time" placeholder="入住时间"
										id="LAY_demorange_s" value="">
									
								</div>

							</div>
							<div class="layui-form-item layui-form-text">
								<label class="layui-form-label">
									<span class='x-red'>*</span>描述
								</label>
								<div class="layui-input-block">
									<textarea id="description" placeholder="请输入内容" name="desc"
										class="layui-textarea"></textarea>
								</div>
							</div>

							<div class="layui-form-item">
								<button id="baocun" class="layui-btn" type="button" lay-filter="add" lay-submit="">
									保存
								</button>
							</div>
							<!--</form>-->
							<div style="height:100px;"></div>
						</div>

					</div>

				</div>
			</form>
		</div>
		<script src="lib/layui/layui.js" charset="utf-8"></script>
		<script src="js/x-layui.js" charset="utf-8"></script>
		<script src="js/jquery.min.js" charset="utf-8"></script>
		<!--<script src="/static/xiyuan/js/jquery.js" charset="utf-8"></script>-->
		<script type="text/javascript">
			//实例化编辑器
			//建议使用工厂方法getEditor创建和引用编辑器实例，如果在某个闭包下引用该编辑器，直接调用UE.getEditor('editor')就能拿到相关的实例
			UE.getEditor('content', {
				initialFrameWidth: 700,
				initialFrameHeight: 200,
			});
		</script>
		<script>
			document.getElementById("fangchanmingcheng").value = fangchan.fangchanmingcheng ; 
			document.getElementById("huzhumingcheng").value = fangchan.huzhumingcheng ;
			document.getElementById("telephone").value = fangchan.telephone ;
			document.getElementById("fangjianshu").value = fangchan.fangjianshu;
			document.getElementById("danyuanhao").value = fangchan.danyuanhao;
			document.getElementById("loucenghao").value = fangchan.loucenghao;
			document.getElementById("LAY_demorange_s").value = fangchan.ruzhushijian;
			document.getElementById("description").value = fangchan.description;
												
		</script>
		
		
		<script>
			layui.use(['laydate', 'element', 'layer', 'form'], function() {
				$ = layui.jquery; //jquery

				laydate = layui.laydate; //日期插件
				lement = layui.element(); //面包导航
				layer = layui.layer; //弹出层

				form = layui.form();
				okLoading.close($);
				form.render();
				var start = {
					min: '1900-01-01 00:00:00',
					max: '2099-06-16 23:59:59',
					istoday: false,
					choose: function(datas) {
						//end.min = datas; //开始日选好后，重置结束日的最小日期
						//end.start = datas //将结束日的初始值设定为开始日
					}
				};

				document.getElementById('LAY_demorange_s').onclick = function() {
					start.elem = this;
					laydate(start);
				};

				//监听提交
				form.on('submit(add)', function(data) {
					let xioaqumingcheng = document.getElementById("fangchan_id").value;
					let dongshu = document.getElementById("building_id").value;
					let fangchanmingcheng = document.getElementById("fangchanmingcheng").value;
					let huzhumingcheng = document.getElementById("huzhumingcheng").value;
					let telephone = document.getElementById("telephone").value;
					let fangjianshu = document.getElementById("fangjianshu").value;
					let danyuanhao = document.getElementById("danyuanhao").value;
					let loucenghao = document.getElementById("loucenghao").value;
					let description = document.getElementById("description").value;
					// let ruzhushijian = document.getElementById("ruzhushijian").value;
					let url = "http://localhost:8080/wuye/FangChanController/add";
					let method = "post";
					let json = {};
					json.xioaqumingcheng = xioaqumingcheng;
					json.dongshu = dongshu;
					json.fangchanmingcheng = fangchanmingcheng;
					json.huzhumingcheng = huzhumingcheng;
					json.telephone = telephone;
					json.fangjianshu = fangjianshu;
					json.danyuanhao = danyuanhao;
					json.loucenghao = loucenghao;
					//json.chuangjianshijian=chuangjianshijian;
					json.description = description;

					rest(url, method, json, function(r) {
						if (r.code == 200) {
							//添加成功
							layer.msg("添加成功", {
								icon: 6,
								time: 2000
							}, function() {
								window.parent.location.reload();
								var index = parent.layer.getFrameIndex(window.name);
								parent.layer.close(index);
							});
						} else {
							layer.msg("添加失败", {
								icon: 5,
								time: 2000
							});
							return false;
						}
					});
					return false;
				});
				// 	var home_name = $("input[name='home_name']").val();
				// 	var householder = $("input[name='householder']").val();
				// 	if (home_name == "") {
				// 		layer.msg('房产名称不能为空', {
				// 			icon: 5,
				// 			time: 2000
				// 		});
				// 		return false;
				// 	}
				// 	if (householder == "") {
				// 		layer.msg('户主名称不能为空', {
				// 			icon: 5,
				// 			time: 2000
				// 		});
				// 		return false;
				// 	}
				// 	var data = data.field;
				// 	$.ajax({
				// 		type: "post",
				// 		url: "/xiyuan/home/add.html",
				// 		data: data,
				// 		dataType: "json",
				// 		success: function(data) {
				// 			//alert(1);
				// 			if (data.status == 1) {
				// 				layer.msg(data.info, {
				// 					icon: 6,
				// 					time: 2000
				// 				}, function() {
				// 					window.parent.location.reload();
				// 					var index = parent.layer.getFrameIndex(window.name);
				// 					parent.layer.close(index);
				// 				});
				// 				return false;

				// 			} else {
				// 				layer.msg(data.info, {
				// 					icon: 5,
				// 					time: 2000
				// 				});
				// 				return false;
				// 			}
				// 		}

				// 	});

				// });
				// form.on('select(aihao)', function(data) {
				// 	communidy();
				// });
				// $(function() {
				// 	communidy();
				// });
				// //communidy();
				// function communidy() {
				// 	var communidy = $("#community_id").val();

				// 	$.ajax({
				// 		url: "/xiyuan/home/building.html",
				// 		type: "post",
				// 		dataType: "json",
				// 		data: {
				// 			communidy: communidy
				// 		},
				// 		success: function(data) {

				// 			var dlen = data.length;
				// 			var str = '';
				// 			for (var i = 0; i < dlen; i++) {
				// 				var dt = data[i];
				// 				str += '<option value="' + dt.id + '">';
				// 				str += dt.buildings_name;
				// 				str += '</option>';
				// 			}

				// 			$("#building_id").html(str);
				// 			form.render('select', 'aihao');
				// 			//form.render('#building_id');

				// 		}
				// 	})
				// }


			})
		</script>
		<!--栏目缩略图上传-->
		<script>
			/*$("#community_id").blur(function(){
        communidy()
    });*/


			//window.onload = communidy;
		</script>

	</body>
</html>